//
// Created by andrew on 2024/8/11.
//



#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#include <iostream>
#include <vector>


using namespace std;

// my_class.h

class MyClass {
public:
    virtual ~MyClass() {}
    virtual void doSomething() const {};
    virtual int calculate(int x, int y) {return 0;};
};

// mock_my_class.h



class MockMyClass : public MyClass {
public:
    MOCK_METHOD(void, doSomething, (), (const));
    MOCK_METHOD(int, calculate, (int x, int y), ());
};

TEST(MyClassTest, DoSomethingTest) {
    MockMyClass mock;

    // 设置预期行为
    EXPECT_CALL(mock, doSomething())
            .Times(3).WillRepeatedly(testing::Invoke([]{
        std::cout << "test" << std::endl;

        /* 模拟的行为 */ }));

    // 调用 mock 方法
    mock.doSomething();
    mock.doSomething();
    mock.doSomething();
}

TEST(MyClassTest, CalculateTest) {
    MockMyClass mock;

    // 设置预期行为
    EXPECT_CALL(mock, calculate(3, 4))
            .Times(1)
            .WillOnce(testing::Return(7));

    // 调用 mock 方法
    int result = mock.calculate(3, 4);
    ASSERT_EQ(result, 7);
}

TEST(DemoTest, demo) {









    EXPECT_STREQ("da" , "da");

}



